package com.service.dao.enums;

import lombok.Getter;
import org.springframework.lang.Nullable;

public enum WalletConfigEnum {

    TRX_FEE(1,"TRX_FEE"),
    COLD_TRON(2,"COLD_TRON"),
    FIL_HOT(3,"FIL_HOT"),
    FIL_COLD(4,"FIL_COLD"),
    ;

    @Getter
    private Integer code;
    @Getter
    private String name;

    WalletConfigEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static WalletConfigEnum codeOf(int statusCode) {
        WalletConfigEnum status = resolve(statusCode);
        if (status == null) {
            throw new IllegalArgumentException("No matching constant for [" + statusCode + "]");
        }
        return status;
    }

    @Nullable
    public static WalletConfigEnum resolve(int statusCode) {
        for (WalletConfigEnum status : values()) {
            if (status.code == statusCode) {
                return status;
            }
        }
        return null;
    }
}
